package com.pgeneral.user.management.controller;


import com.pgeneral.user.management.config.ResultBean;
import com.pgeneral.user.management.entity.UserSopScopeData;
import com.pgeneral.user.management.entity.UserUserInfo;
import com.pgeneral.user.management.service.UserSopscopedataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 权限表
 *
 * @author lenovo
 */
@Slf4j
@RestController
@RequestMapping("/user/sopScopeData")
public class UserSopScopeDataController {

    @Autowired
    private UserSopscopedataService service;

    /**
     * 查询所有权限信息,如果没有权限返回空List
     *
     * @return
     */
//    @LogAnnotation(module="/user/sopScopeData",operator = "/getInfo 查询所有权限信息,如果没有权限返回空List")
    @GetMapping(value = "/getInfo")
    public ResultBean getUserSopScopeDataAll() {
        log.info("查询所有权限信息,如果没有权限返回空List");
        List<UserSopScopeData> userSopScopeDataList = service.getUserSopScopeDataAll();
        return ResultBean.Success(userSopScopeDataList);

    }

    /**
     * 根据权限ID（scopeId）找有该权限的角色下的所有人
     *
     * @param scopeId 权限ID
     * @return
     */
    @GetMapping(value = "/getUserInfoByScopeId")
    public ResultBean getUserInfoByScopeId(@RequestParam(value = "scopeId") String scopeId) {
        log.info("查询所有权限信息,如果没有权限返回空List");
        List<UserUserInfo> userUserInfoList = service.getUserInfoByScopeId(scopeId);
        return ResultBean.Success(userUserInfoList);

    }


}
